<?php
namespace App\Model;

use PhalApi\Model\NotORMModel as NotORM;

/**

CREATE TABLE `phalapi_curd` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`title` varchar(20) DEFAULT NULL,
`content` text,
`state` tinyint(4) DEFAULT NULL,
`post_date` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

 */

class USER extends NotORM
{

    protected function getTableName($id)
    {
        return 'user';
    }

    public function getUserByToken($token) {
        return \PhalApi\DI()->notorm->user
            // ->select('id')
            ->where('token', $token)
            ->fetchRow();
    }

    public function getUserById($id) {
        return \PhalApi\DI()->notorm->user
            // ->select('id')
            ->where('id', $id)
            ->fetchRow();
    }

    public function getUserByIdLogin($id, $time) {
        return \PhalApi\DI()->notorm->user
            // ->select('id')
            ->where("id in ($id)")
            ->where("login_time > $time")
            ->fetchAll();
    }

    public function getUserByPhone($phone) {
        return \PhalApi\DI()->notorm->user
            // ->select('id')
            ->where('telphone', $phone)
            ->fetchRow();
    }
}